<template>
	<el-card>
		<!-- 搜索 -->
		<el-form :model="searchData" inline ref="searchFormRef" v-resize="searchResize">
			<el-form-item label="内容" prop="content">
				<el-input v-model="searchData.content" clearable placeholder=""></el-input>
			</el-form-item>
			<el-form-item label="状态" prop="state">
				<el-select v-model="searchData.state" clearable placeholder="">
					<el-option value="SUCCESS" label="已处理"></el-option>
					<el-option value="WAIT" label="待处理"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button icon="el-icon-search" type="primary" size="small" @click="searchClick">搜索</el-button>
				<el-button icon="el-icon-refresh" size="small" @click="resetClick">重置</el-button>
			</el-form-item>
		</el-form>

		<!-- 表格渲染 -->
		<YwTable ref="tableRef" :searchData="searchData" :tableProps="tableProps" api="appFankuiFindAllByPage">
			<el-table-column slot="table_oper" label="操作">
				<template v-slot="scope">
					<el-button v-if="scope.row.state == 'WAIT'" type="primary" @click="setStateClick(scope.row)">已处理</el-button>
				</template>
			</el-table-column>
		</YwTable>
	</el-card>
</template>

<script>
	export default {
		data() {
			return {
				searchData: {
					content: null,
					state: null,
				},
				tableProps: [
					{
						label: "内容",
						prop: "content"
					},
					{
						label: "图片",
						prop: "filesShow",
						type: "pictures"
					},
					{
						label: "用户手机",
						prop: "userPhone"
					},
					{
						label: "状态",
						prop: "state",
						type: "tag",
						result: [{
								code: 'SUCCESS',
								type: "primary",
								text: "已处理"
							},
							{
								code: 'WAIT',
								type: "info",
								text: "未处理"
							},
						],
					},
				],
			};
		},
		mounted() {
			this.$nextTick(() => {
				this.searchClick()
			})
		},
		methods: {
			//设置表格高度
			searchResize(data) {
				this.$refs.tableRef.refreshSize(data)
			},
			//搜索按钮
			searchClick() {
				this.$refs.tableRef.shuaxin(this.searchData)
			},
			//重置按钮
			resetClick() {
				this.$refs.searchFormRef.resetFields();
				this.searchClick()
			},
			//设置状态
			setStateClick(row) {
				this.$api.appFankuiSetState({
					id:row.id,
					state:"SUCCESS"
				}).then(data=>{
					this.searchClick()
				})
			},
		},
	};
</script>

<style lang="scss" scoped>

</style>
